/*  Imakefile for Andrew Consortium's bison-A2.0
*/

/*  installed names of parser files  */
PFILE = bison.simple
PFILE1 = bison.hairy

DEFINES  =  -DXPFILE='((char*)AndrewDir('\"/etc/$(PFILE)\"'))' \
	 -DXPFILE1='((char*)AndrewDir('\"/etc/$(PFILE1)\"'))'

OBJECTS = LR0.o allocate.o closure.o conflicts.o derives.o files.o	\
	  getargs.o getopt.o getopt1.o gram.o lalr.o lex.o		\
	  main.o nullable.o output.o print.o reader.o reduce.o symtab.o	\
	  version.o warshall.o

NormalObjectRule()

/*  make and install the program */
ProgramTarget(bison, $(OBJECTS),  $(UTILLIB), )
InstallProgram(bison, ${DESTDIR}/bin)

/* When untarred, the timestamps on bison.info* may be earlier than 
     bison.texinfo.  So if we have  
		bison.info: bison.texinfo
			makeinfo bison.texinfo
     then this rule will trigger every time we try to install.
     It gives an error if makeinfo is not installed.

     To avoid the problem, we give the installer the option of 
     making bison.info* or touching it to avoid makeinfo
*/
nomakeinfo:
	@sh -c 'for i in  bison.info*;  do  \
		cp $$i $$i.new; rm -f $$i; mv $$i.new $$i; \
		done; \
		exit 0'
	chmod 644 bison.info*
makeinfo:
	makeinfo bison.texinfo 
	
bison.info: bison.texinfo
	@echo '***'
	@echo      If you have changed bison.texinfo, run \`make makeinfo\`
	@echo      If you have not changed bison.texinfo, run \`make nomakeinfo\`
	@echo '***'

/*  install documents  */
MkdirTarget(${DESTDIR}/doc/syntax)
InstallDocs(bison.1, ${DESTDIR}/doc/syntax) 
InstallDocs(bison.info bison.info-?, ${DESTDIR}/doc/syntax)

/*  install the bison parsers  */
/*  Copy bison.simple, inserting directory name into the #line commands. */ 
tmp-simple: bison.simple
	sed -e "/^#line/ s|bison|$(DESTDIR)/etc/bison|" 	\
			< bison.simple   > tmp-simple
InstallFileToFile(tmp-simple, ${INSTLIBFLAGS}, ${DESTDIR}/etc/${PFILE})
InstallFiles(${PFILE1}, ${INSTLIBFLAGS}, ${DESTDIR}/etc)

CleanTarget(config.status tmp-simple ness.tab* ness.act *.output *.guard.c *.stype.h)

DependTarget()


/* to make the Bison distribution files in familiar gnu form,
	we delete three files and
	convert all instances of sys.h to system.h
*/
distribution: clean
	rm -f RCS Imakefile Makefile ness.y 
	mv sys.h system.h
	for f in Makefile.in *.c; do \
		(sed "/andrewos.h/s/andrewos.h/system.h/" $$f > $$f.s ; \
			rm -f $$f; mv $$f.s $$f) done
